package chapter1014.hero;

import chapter1014.item.Item;

public class Hero {
    private String name; //姓名
    private float hp; //血量
    private float armor; //护甲
    private int moveSpeed; //移动速度
    private Item[] items;
    private int n = items.length;

    public Hero(){}

    public Hero(String name, float hp, float armor, int moveSpeed,int size) {
        this.name = name;
        this.hp = hp;
        this.armor = armor;
        this.moveSpeed = moveSpeed;
        this.items = new Item[size];
    }

    public void buy(Item item){
        System.out.println(name + " buy a  " + item.getName() + " price is "+ item.getPrice());
        if( n == 0) return;
        n = n - 1;
        items[n] = item;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", hp=" + hp +
                ", armor=" + armor +
                ", moveSpeed=" + moveSpeed +
                '}';
    }


    public Item[] getItems() {
        return items;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getHp() {
        return hp;
    }

    public void setHp(float hp) {
        this.hp = hp;
    }

    public float getArmor() {
        return armor;
    }

    public void setArmor(float armor) {
        this.armor = armor;
    }

    public int getMoveSpeed() {
        return moveSpeed;
    }

    public void setMoveSpeed(int moveSpeed) {
        this.moveSpeed = moveSpeed;
    }

    public void setItems(Item[] items) {
        this.items = items;
    }
}

//public String toString(){
//    return "name is " + name + "hp is " + hp + "armor is " + armor + "moveSpeed is " + moveSpeed;
//}
//
//public void info(){
//    System.out.println("name is " + name + "hp is " + hp + "armor is " + armor + "moveSpeed is " + moveSpeed);
//}
